package com.sailfish.springbootdemo.dao.db7;

import com.sailfish.springbootdemo.common.DB7TableName;
import com.sailfish.springbootdemo.pojo.db7.TbFlowCompPkg;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface TbFlowCompPkgDao {
    @Select("<script>" +
            "select " +
            "* " +
            "from " + DB7TableName.TB_FLOW_COMP_PKG + " " +
            "where flow_no = #{flowNo} and flow_level = #{flowLevel}" +
            "</script>"
    )
    List<TbFlowCompPkg> getTbFlowCompPkgByFlowNo(@Param("flowNo") String flowNo,
                                           @Param("flowLevel") Integer flowLevel);

    @Insert("<script>" +
            "insert into " + DB7TableName.TB_FLOW_COMP_PKG + " " +
            "( "+
            "flow_no, " +
            "flow_level, " +
            "create_time, " +
            "create_user, " +
            "update_time, " +
            "update_user, " +
            "pkg_name, " +
            "assembly_type, " +
            "foot_num, " +
            "is_orientation, " +
            "body_length, " +
            "body_width, " +
            "pad_airgap_min, " +
            "pitch_o2c_x, " +
            "pitch_o2c_y, " +
            "is_size_not_fit, " +
            "is_grid_design, " +
            "is_twins_design, " +
            "is_special_design, " +
            "is_window_open, " +
            "is_small_air_gap, " +
            "is_vpl_model_imported, " +
            "is_vpl_parameters_imported, " +
            "is_pkg_imported, " +
            "is_required_eda_lib, " +
            "is_required_vpl_pkg, " +
            "timeliness, " +
            "quality, " +
            "overall_evaluation, " +
            "is_from_vpl"+
            ")"+
            "values "+
            "<foreach collection=\"entities\" item=\"entity\" separator=\",\">" +
            "(" +
            "#{entity.flow_no}, " +
            "#{entity.flow_level}, " +
            "#{entity.create_time}, " +
            "#{entity.create_user}, " +
            "#{entity.update_time}, " +
            "#{entity.update_user}, " +
            "#{entity.pkg_name}, " +
            "#{entity.assembly_type}, " +
            "#{entity.foot_num}, " +
            "#{entity.is_orientation}, " +
            "#{entity.body_length}, " +
            "#{entity.body_width}, " +
            "#{entity.pad_airgap_min}, " +
            "#{entity.pitch_o2c_x}, " +
            "#{entity.pitch_o2c_y}, " +
            "#{entity.is_size_not_fit}, " +
            "#{entity.is_grid_design}, " +
            "#{entity.is_twins_design}, " +
            "#{entity.is_special_design}, " +
            "#{entity.is_window_open}, " +
            "#{entity.is_small_air_gap}, " +
            "#{entity.is_vpl_model_imported}, " +
            "#{entity.is_vpl_parameters_imported}, " +
            "#{entity.is_pkg_imported}, " +
            "#{entity.is_required_eda_lib}, " +
            "#{entity.is_required_vpl_pkg}, " +
            "#{entity.timeliness}, " +
            "#{entity.quality}, " +
            "#{entity.overall_evaluation}," +
            "#{entity.is_from_vpl}"+
            ")"+
            "</foreach>"+
            "</script>"
    )
    Integer insertTbFlowCompPkgBatch(@Param("entities") List<TbFlowCompPkg> entities);


    @Update("<script>" +
            "update " + DB7TableName.TB_FLOW_COMP_PKG + " " +
            "set " +
            " <if test='entity.pkg_name != null'>pkg_name = #{entity.pkg_name},</if>" +
            " <if test='entity.assembly_type != null'>assembly_type = #{entity.assembly_type},</if>" +
            " <if test='entity.foot_num != null'>foot_num = #{entity.foot_num},</if>" +
            " <if test='entity.is_orientation != null'>is_orientation = #{entity.is_orientation},</if>" +
            " <if test='entity.body_length != null'>body_length = #{entity.body_length},</if>" +
            " <if test='entity.body_width != null'>body_width = #{entity.body_width},</if>" +
            " <if test='entity.pad_airgap_min != null'>pad_airgap_min = #{entity.pad_airgap_min},</if>" +
            " <if test='entity.pitch_o2c_x != null'>pitch_o2c_x = #{entity.pitch_o2c_x},</if>" +
            " <if test='entity.pitch_o2c_y != null'>pitch_o2c_y = #{entity.pitch_o2c_y},</if>" +
            " <if test='entity.is_size_not_fit != null'>is_size_not_fit = #{entity.is_size_not_fit},</if>" +
            " <if test='entity.is_grid_design != null'>is_grid_design = #{entity.is_grid_design},</if>" +
            " <if test='entity.is_twins_design != null'>is_twins_design = #{entity.is_twins_design},</if>" +
            " <if test='entity.is_special_design != null'>is_special_design = #{entity.is_special_design},</if>" +
            " <if test='entity.is_window_open != null'>is_window_open = #{entity.is_window_open},</if>" +
            " <if test='entity.is_small_air_gap != null'>is_small_air_gap = #{entity.is_small_air_gap},</if>" +
            " <if test='entity.is_vpl_model_imported != null'>is_vpl_model_imported = #{entity.is_vpl_model_imported},</if>" +
            " <if test='entity.is_vpl_parameters_imported != null'>is_vpl_parameters_imported = #{entity.is_vpl_parameters_imported},</if>" +
            " <if test='entity.is_pkg_imported != null'>is_pkg_imported = #{entity.is_pkg_imported},</if>" +
            " <if test='entity.is_required_eda_lib != null'>is_required_eda_lib = #{entity.is_required_eda_lib},</if>" +
            " <if test='entity.is_required_vpl_pkg != null'>is_required_vpl_pkg = #{entity.is_required_vpl_pkg},</if>" +
            " <if test='entity.timeliness != null'>timeliness = #{entity.timeliness},</if>" +
            " <if test='entity.quality != null'>quality = #{entity.quality},</if>" +
            " <if test='entity.overall_evaluation != null'>overall_evaluation = #{entity.overall_evaluation},</if>" +
            " update_time = #{entity.update_time}," +
            " update_user = #{entity.update_user}" +
            " where id = #{entity.id}" +
            //"where flow_no = #{entity.flow_no} and flow_level = #{entity.flow_level}" +
            "</script>"
    )
    Integer updateTbFlowCompPkg(@Param("entity") TbFlowCompPkg entity);

    @Update("<script>" +
            "update " + DB7TableName.TB_FLOW_COMP_PKG + " " +
            "set " +
            " <if test='entity.pkg_name != null'>pkg_name = #{entity.pkg_name},</if>" +
            " <if test='entity.assembly_type != null'>assembly_type = #{entity.assembly_type},</if>" +
            " <if test='entity.foot_num != null'>foot_num = #{entity.foot_num},</if>" +
            " <if test='entity.is_orientation != null'>is_orientation = #{entity.is_orientation},</if>" +
            " <if test='entity.body_length != null'>body_length = #{entity.body_length},</if>" +
            " <if test='entity.body_width != null'>body_width = #{entity.body_width},</if>" +
            " <if test='entity.pad_airgap_min != null'>pad_airgap_min = #{entity.pad_airgap_min},</if>" +
            " <if test='entity.pitch_o2c_x != null'>pitch_o2c_x = #{entity.pitch_o2c_x},</if>" +
            " <if test='entity.pitch_o2c_y != null'>pitch_o2c_y = #{entity.pitch_o2c_y},</if>" +
            " <if test='entity.is_size_not_fit != null'>is_size_not_fit = #{entity.is_size_not_fit},</if>" +
            " <if test='entity.is_grid_design != null'>is_grid_design = #{entity.is_grid_design},</if>" +
            " <if test='entity.is_twins_design != null'>is_twins_design = #{entity.is_twins_design},</if>" +
            " <if test='entity.is_special_design != null'>is_special_design = #{entity.is_special_design},</if>" +
            " <if test='entity.is_window_open != null'>is_window_open = #{entity.is_window_open},</if>" +
            " <if test='entity.is_small_air_gap != null'>is_small_air_gap = #{entity.is_small_air_gap},</if>" +
            " <if test='entity.is_vpl_model_imported != null'>is_vpl_model_imported = #{entity.is_vpl_model_imported},</if>" +
            " <if test='entity.is_vpl_parameters_imported != null'>is_vpl_parameters_imported = #{entity.is_vpl_parameters_imported},</if>" +
            " <if test='entity.is_pkg_imported != null'>is_pkg_imported = #{entity.is_pkg_imported},</if>" +
            " <if test='entity.is_required_eda_lib != null'>is_required_eda_lib = #{entity.is_required_eda_lib},</if>" +
            " <if test='entity.is_required_vpl_pkg != null'>is_required_vpl_pkg = #{entity.is_required_vpl_pkg},</if>" +
            " <if test='entity.timeliness != null'>timeliness = #{entity.timeliness},</if>" +
            " <if test='entity.quality != null'>quality = #{entity.quality},</if>" +
            " <if test='entity.overall_evaluation != null'>overall_evaluation = #{entity.overall_evaluation},</if>" +
            " update_time = #{entity.update_time}," +
            " update_user = #{entity.update_user}" +
            //" where id = #{entity.id}" +
            " where flow_no = #{entity.flow_no} and flow_level = #{entity.flow_level}" +
            "</script>"
    )
    Integer updateTbFlowCompPkgByFlowNo(@Param("entity") TbFlowCompPkg entity);

    @Delete("<script>" +
            "delete from " + DB7TableName.TB_FLOW_COMP_PKG + " " +
            "where flow_no = #{flowNo} and flow_level = #{flowLevel}" +
            "</script>"
    )
    Integer deleteTbFlowCompPkg(@Param("flowNo") String flowNo, @Param("flowLevel") Integer flowLevel);

    @Delete("<script>" +
            "delete from " + DB7TableName.TB_FLOW_COMP_PKG + " " +
            "where flow_no = #{flowNo}" +
            "</script>"
    )
    Integer deleteTbFlowCompPkgByFlowNo(@Param("flowNo") String flowNo);

}
